package com.bosssoft.user.permission.center.serve.api;

import com.bosssoft.user.permission.center.serve.pojo.dto.Id;
import com.bosssoft.user.permission.center.serve.pojo.dto.IdVersion;
import com.bosssoft.user.permission.center.serve.pojo.query.SubSystemQuery;
import com.bosssoft.user.permission.center.serve.pojo.vo.SubSystemVO;
import common.data.commonresponse.CommonPage;
import common.data.commonresponse.CommonResponse;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * @interfaceName: SubSystemApi
 * @description:
 * @author: lanyukai
 * @date: 2024/6/13 9:11
 * @since 1.0
 **/
@Api(tags = "子系统管理", value = "/api/v1/permission/subsystem")
@RequestMapping("/api/v1/permission/subsystem")
@Validated
//@CrossOrigin(origins = "*")
public interface SubSystemApi {
    /**
     * 根据查询条件查询子系统信息
     * @param subSystemQuery 查询条件
     * @return 子系统信息
     */
    @ApiOperation(value = "查询子系统列表接口",notes = "支持模糊查询")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @GetMapping("/select")
    CommonResponse<CommonPage<SubSystemVO>> selectSubSystemWithQuery(
            @NotNull @ApiParam(value = "子系统信息表单", required = true)
            SubSystemQuery subSystemQuery);

    /**
     * 根据子系统id获得该子系统信息
     * @param id 子系统id
     * @return 该id对应的子系统信息
     */
    @ApiOperation(value = "子系统编辑接口传入的id",notes = "子系统编辑时需要查询的该子系统信息")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @GetMapping("/get/{id}")
    CommonResponse<SubSystemVO> selectSubSystemById(
            @NotNull @ApiParam(value = "子系统id", required = true)
            @PathVariable Long id);

    /**
     * 新增子系统信息
     * @author lanyukai
     * @date 2024/06/13 15:30
     * @param subSystemVO 用户输入的子系统信息
     * @return 返回是否新增成功
     */
    @ApiOperation(value = "新增子系统接口", notes = "用户需要写入新增的子系统信息")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @PostMapping("/addition")
    CommonResponse<Boolean> addSubSystem(
            @NotNull @RequestBody @ApiParam(value = "新增的子系统信息", required = true)
            SubSystemVO subSystemVO);

    /**
     * 根据id集合复制子系统
     * @author lanyukai
     * @date 2024/06/16 15:38
     * @param ids id集合
     * @return 是否复制成功
     */
    @ApiOperation(value = "复制子系统", notes = "用户选择多个子系统进行复制")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @PostMapping("/copy")
    CommonResponse<Boolean> copySubSystem(
            @NotNull @RequestBody @ApiParam(value = "复制的子系统信息", required = true)
            Id[] ids);

    /**
     * 修改子系统信息
     * @author lanyukai
     * @date 2024/06/13 15:30
     * @param subSystemVO 用户输入的子系统信息
     * @return 返回是否修改成功
     */
    @ApiOperation(value = "修改子系统接口", notes = "用户需要写入修改的子系统信息")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @PutMapping("/modification")
    CommonResponse<Boolean> updateSubSystem(
            @NotNull @RequestBody @ApiParam(value = "修改的子系统信息", required = true)
            SubSystemVO subSystemVO);

    /**
     * 根据子系统id删除指定子系统
     * @author lanyukai
     * @date 2024/06/13 19:52
     * @param id id
     * @return 是否删除成功
     */
    @ApiOperation(value = "删除指定子系统的接口", notes = "用户选择删除的子系统信息")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @DeleteMapping("/deletion")
    CommonResponse<Boolean> deleteSubSystemById(
            @NotNull @ApiParam(value = "子系统id", required = true)
            Long id);

    /**
     * 根据子系统id集合批量删除指定子系统
     * @author lanyukai
     * @date 2024/06/13 19:53
     * @param ids id集合
     * @return 是否删除成功
     */
    @ApiOperation(value = "删除子系统接口", notes = "用户需要写入删除的子系统信息")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @DeleteMapping("/batch")
    CommonResponse<Boolean> deleteSubSystemsByIds(
            @NotEmpty @ApiParam(value = "子系统id集合", required = true)
            @RequestBody @Validated
            Id[] ids);

    /**
     * 设置子系统启用、停用状态
     * @author lanyukai
     * @date 2024/06/13 19:53
     * @param id 子系统id
     * @return 是否设置成功，子系统启用中则无法设置停用，子系统停用中则启用子系统
     */
    @ApiOperation(value = "设置子系统状态", notes = "用户选择启用/停用子系统")
    @ApiResponses({
            @ApiResponse(code = 0,message = "请求成功"),
            @ApiResponse(code=-1,message = "没有更新记录,非0码则代表失败")
    })
    @PutMapping("/status/{id}")
    CommonResponse<Boolean> setSubSystemStatus(
            @NotNull @ApiParam(value = "子系统id", required = true) @PathVariable
            Long id);
}
